package main

import (
	"blog/dao"
	"flag"
	"fmt"
)

func main() {
	var action string
	flag.StringVar(&action, "action", "", "createIndex|mapping|indexAll|indexOne")
	flag.Parse()

	if action == "createIndex" {
		err := dao.EsIndexCreate(dao.EsConf["INDEX_NAME_POST"])
		if err != nil {
			fmt.Println(err)
		}

		return
	}

	if action == "delete" {
		err := dao.EsIndexDelete(dao.EsConf["INDEX_NAME_POST"])
		if err != nil {
			fmt.Println(err)
		}

		return
	}

	if action == "mapping" {
		dao.EsIndexMapping(dao.EsConf["INDEX_NAME_POST"], dao.EsConf["INDEX_POST_MAPPING"])
		return
	}

	if action == "indexAll" {
		dao.EsIndexAll()
		return
	}
}
